var ws, aid;
document.addEventListener('plusready', function(){
	ws = plus.webview.currentWebview();
	aid = ws.aid;
	console.log(aid); 
	showWating();
	$.ajax({
		type:"get",
		url:apiRoot+"/home/bespoke/bespoke",
		data :{aid :aid},
		dataType :'json',
		success :function(data){
			plus.nativeUI.closeWaiting();
//			console.log(JSON.stringify(data));
			if(data.photo.length >0){
				var str = '<div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="'+webRoot + data.photo[(data.photo).length-1] +'"></a></div>';
				$.each(data.photo, function(k, v) {
					str += '<div class="mui-slider-item">'+
				          '<a href="#">'+
				            '<img src="'+webRoot+v+'">'+
				          '</a>'+
				        '</div>';
				});
				str += '<div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="'+webRoot + data.photo[0] +'"></a></div>';
				$('.mui-slider-loop').html(str);
			}
			$('.text-jianli').append(data.info);
			$('.weishu').text(data.overnum+'位');
			if(data.grade)$('.grade').text(data.grade);
			if(data.photo){
				var arr = '';
				$.each(data.tel, function(k, v) {
					arr += '<p>'+v.name+'</p>';
					$.each(v.tel, function(k1, v1) {
						arr += '<p class="telp">'+v1+'</p>';
					});
				});
				$('.phone-tc').append(arr);
			}
			//点击打电话
			$('.telp').on('tap', function(){
				plus.device.dial($(this).text(), true);
			})
			//点击导航
			$('.daohang').on('tap', function(){
				goNewPage('yuyue-daoh.html',{coord:data.coord, title:data.title, address:data.address});
			})
			//点击查看医生
			$('.mui-bar-footer').on('tap', function(){
				goNewPage('yuyue-look.html',{aid:aid, title:data.title});
			})
		},
		error :function(e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
}, false)